package com.bosssoft.setp.controller;

import com.bosssoft.setp.pojo.vo.CommonVO;
import com.bosssoft.setp.pojo.vo.CoureDetailVO;
import com.bosssoft.setp.pojo.vo.CourseTypeVO;
import com.bosssoft.setp.pojo.vo.PackageVO;
import com.bosssoft.setp.service.CourseService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 课程相关接口控制器类定义
 *
 * @author clt
 */
@RestController
@RequestMapping("/api/course/")
public class CourseController {
    @Resource
    private CourseService courseService;

    /**
     * 获取顶级课程分类
     * @return
     */
    @RequestMapping("/package")
    public CommonVO<List<PackageVO>> getPackages() {
        return new CommonVO<>(courseService.getPackages());
    }

    /**
     * 获取某一课程分类下的子分类和课程
     * @param courseId
     * @return
     */
    @RequestMapping("/{courseId}")
    public CommonVO<CourseTypeVO> getCourseTypeVO(@PathVariable("courseId") Long courseId) {
        return new CommonVO(courseService.getCourseTypeVO(courseId));
    }

    /**
     * 获取某一课程对应的资源
     * @param courseId
     * @return
     */
    @RequestMapping("/files/{courseId}")
    public CommonVO<CoureDetailVO> getCourseDetailVO(@PathVariable("courseId") Long courseId) {
        return new CommonVO(courseService.getCourseDetailVO(courseId));
    }
}